import type { ApiPagination, ApiPaginationParams } from '#types/utils'
import { requestClient } from '../request'
import type {
    productTaskLinkItemForm,
    productTaskLinkPageListItem
} from './model/productTaskLinkModel'

// 商品任务推广
export default class ProductTaskLinkApi {
    static get inst() {
        return ProductTaskLinkApi._inst || (ProductTaskLinkApi._inst = new ProductTaskLinkApi())
    }
    private static _inst: ProductTaskLinkApi
    add(params: Partial<productTaskLinkItemForm>) {
        return requestClient.post<null>('/goodsExtend/add', params)
    }
    delete(ids: Array<number | string>) {
        return requestClient.delete<null>(`/goodsExtend/delete/${ids}`)
    }
    edit(id: number | string, params: Partial<productTaskLinkItemForm>) {
        return requestClient.put<null>(`/goodsExtend/edit/${id}`, params)
    }
    /**
     * 分页
     * @param params
     */
    getPageList(params: ApiPaginationParams<{ username?: string }>) {
        return requestClient.get<ApiPagination<productTaskLinkPageListItem>>('/goodsExtend/index', {
            params
        })
    }
}
